//
//  DKPanCardSigleView.m
//  DanKU
//
//  Created by 吴斌 on 2023/11/5.
//

#import "DKPanCardSigleView.h"
@interface DKPanCardSigleView()
@property (nonatomic, strong)UIImageView * pancardImgView;
@property (nonatomic, strong)UILabel * pancardNameLab;
@end
@implementation DKPanCardSigleView
-(instancetype)init{
    if(self == [super init]){
        [self dk_addSubView];
    }
    return self;
}
- (void)dk_addSubView{
    self.pancardImgView = [[UIImageView alloc] init];
    self.pancardImgView.userInteractionEnabled = YES;
    [self addSubview:self.pancardImgView];
    [self.pancardImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(DK_IsWidthScale(0)));
        make.right.equalTo(@(DK_IsWidthScale(0)));
        make.top.equalTo(@(DK_IsWidthScale(0)));
        make.height.equalTo(@(DK_IsWidthScale(48)));
    }];
    UIView *pancardBottomView = [[UIView alloc] init];
    pancardBottomView.backgroundColor = [UIColor clearColor];
    [self addSubview:pancardBottomView];
    [pancardBottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.pancardImgView.mas_bottom).offset(DK_IsWidthScale(14));
        make.height.equalTo(@(DK_IsWidthScale(14)));
        make.centerX.equalTo(self);
    }];
    UIImageView * dk_AuthCardCloseImgView = [[UIImageView alloc] init];
    dk_AuthCardCloseImgView.userInteractionEnabled = YES;
    dk_AuthCardCloseImgView.image = DK_GetImage(@"dk_AuthCardFailIcon");
    [pancardBottomView addSubview:dk_AuthCardCloseImgView];
    [dk_AuthCardCloseImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(DK_IsWidthScale(0)));
        make.centerY.equalTo(pancardBottomView);
        make.width.equalTo(@(DK_IsWidthScale(10)));
        make.height.equalTo(@(DK_IsWidthScale(10)));
    }];
    self.pancardNameLab = [[UILabel alloc] init];
    self.pancardNameLab.textColor = DK_Hex(@"#999999");
    self.pancardNameLab.font = DK_FONT_Regular(10);
    [pancardBottomView addSubview:self.pancardNameLab];
    [self.pancardNameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(dk_AuthCardCloseImgView.mas_right).offset(DK_IsWidthScale(2));
        make.right.equalTo(@(DK_IsWidthScale(0)));
        make.top.equalTo(@(DK_IsWidthScale(0)));
        make.bottom.equalTo(@(DK_IsWidthScale(0)));
    }];
}
-(void)setPanCardName:(NSString *)panCardName{
    _panCardName = panCardName;
    if([_panCardName isEqualToString:@"Blurred"]){
        self.pancardImgView.image = DK_GetImage(@"dk_AuthCardBlurred");
    }else if ([_panCardName isEqualToString:@"Incomplete"]){
        self.pancardImgView.image = DK_GetImage(@"dk_AuthCardIncomplete");
    }else if ([_panCardName isEqualToString:@"Overexposed"]){
        self.pancardImgView.image = DK_GetImage(@"dk_AuthCardOverexposed");
    }
    self.pancardNameLab.text = _panCardName;
}
@end
